<template>
  <view class="consultation-wrapper">
    <!-- 顶部标题 -->
    <view class="header">
      <text class="header-title">咨询服务</text>
      <text class="header-description">请输入您的问题，我们将尽快为您解答。</text>
    </view>

    <!-- 问题输入区域 -->
    <view class="input-wrapper">
      <textarea v-model="question" placeholder="请输入您的问题..." class="input-field" />
    </view>

    <!-- 提交按钮 -->
    <view class="submit-wrapper">
      <button class="submit-button" @tap="submitQuestion">提交咨询</button>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      // 用户输入的问题
      question: ''
    };
  },
  
  onLoad() {
    const token = uni.getStorageSync('token');
    if (!token) {
      uni.redirectTo({ url: '/pages/login/index' });
      return;
    }
  },
  
  onShow() {
    const token = uni.getStorageSync('token');
    if (!token) {
      uni.redirectTo({ url: '/pages/login/index' });
    }
  },

  methods: {
    // 提交问题
    submitQuestion() {
      if (!this.question.trim()) {
        uni.showToast({
          title: '请输入您的问题',
          icon: 'none'
        });
        return;
      }

      // 这里可以做API调用，提交问题到服务器
      uni.showToast({
        title: '咨询已提交，等待回复',
        icon: 'success'
      });

      // 提交后清空输入框
      this.question = '';
    }
  }
};
</script>

<style>
.consultation-wrapper {
  background: linear-gradient(135deg, rgba(170, 207, 252, 1) 0%, rgba(187, 208, 251, 1) 50%, rgba(178, 236, 248, 1) 100%);
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  padding: 40rpx;
}

.header {
  text-align: center;
  margin-bottom: 40rpx;
}

.header-title {
  font-size: 40rpx;
  font-weight: bold;
  color: #333333;
}

.header-description {
  font-size: 28rpx;
  color: #666666;
  margin-top: 10rpx;
}

.input-wrapper {
  width: 100%;
  margin-bottom: 40rpx;
}

.input-field {
  width: 100%;
  height: 200rpx;
  padding: 20rpx;
  border-radius: 10rpx;
  border: 1px solid #cccccc;
  font-size: 28rpx;
  color: #333333;
  background-color: rgba(255, 255, 255, 0.8);
  resize: none;
}

.submit-wrapper {
  width: 100%;
  text-align: center;
}

.submit-button {
  background-color: #5e59ff;
  color: white;
  font-size: 32rpx;
  padding: 20rpx 50rpx;
  border-radius: 10rpx;
  cursor: pointer;
  box-shadow: 0 4rpx 10rpx rgba(0, 0, 0, 0.1);
}
</style>
